<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <script type="text/javascript">
    
 var userManager = function(){
	 
	 var userListTable = {};
	 var selectMenuObj ;
	 
	 var getRawData = function(){
		var rows = $("#userTab tr");
		   $.each(rows, function(index, row) {
			   if(index>0){
				  $(row).mouseover(function(){
			   			$(row).addClass("info");
			  			$(row).siblings().removeClass("info");
			  	  });
			    }
		   });
		}
	 var initUserList = function() {
	 
		 
		 
	userListTable =  $('#userTab').dataTable({	
		fnDrawCallback : getRawData,
		"oLanguage": {
            "sInfoEmpty": "",
            "sInfo": "当前第 _START_ - _END_ 个&nbsp;总共 _TOTAL_ 个",
            "sEmptyTable":"没有找到符合条件的数据",
            "sLoadingRecords": "加载中...",
            "sSearch": "<i class=\"fa fa-search\"></i>&nbsp;搜索",
            "oPaginate": {"sFirst": "首页","sLast": "尾页","sNext": "下一页","sPrevious": "上一页"}
        },
        "sPaginationType": "bootstrap",
        "sDom" : '<<"pull-left tableSearch"f>>rt<<"col-sm-6"i><"col-sm-6"p>>',
//         "sDom":'<<"pull-left"f>>rt<<"col-sm-6"i><"col-sm-6"p>>',
        "iDisplayLength": 10, // default record count per page
        "sAjaxSource": ctx + '/sys/user/list.do', 
        "fnServerData" : function(sSource, aDataSet, fnCallback) {  
			 var searchText = $('#sSearch').val()==null?"":$('#sSearch').val();
			
			 aDataSet.push({"name":"sSearch","value":searchText});
			 
                       $.ajax({  
                           "dataType" : 'json',  
                           "type" : "GET",  
                           "url" : sSource,  
                           "data" : aDataSet,  
                           "success" : fnCallback  
                       });  
                   }  , 
    	"sServerMethod": "get",
        "serverSide": true,
        "bAutoWidth": false,
        "bServerSide" : true,
        "bFilter" : false,// 搜索栏
        "bSort" : false,// 排序
        "aoColumns": [{
            "mData": "SWJG_DM",
            "sTitle": "机构代码",
            "visible": false,
            "sWidth": "0px"
        },{
            "mData": "LOGIN_NAME",
            "sTitle": "登录名",
            "sWidth": "15%"
        },{
            "mData": "REAL_NAME",
            "sTitle": "姓名",
            "sWidth": "10%"
        },{
            "mData": "USER_TYPE",
            "sTitle": "用户类型",
            "sWidth": "15%",
            "mRender":function(data, type, row){
            	if(data == '1'){
            		return '系统管理员';
            	}else if(data == '2'){
            		return '委派用户';
            	}else{
            		return '普通用户';
            	}
            }
        },  {
            "mData": "MC_J",
            "sTitle": "机构名称",
            "sWidth": "30%"
        }, {
            "mData": "TEL",
            "sTitle": "联系电话",
            "sWidth": "15%",
            "mRender":function(data, type, row){
            	if(data == '' || data == null){
            		return '';
            	}else{
            		return data;
            	}
            }
        }, {
            "mData": "LOGIN_NAME",
            "sTitle": "操作",
            "sWidth": "15%",
            "mRender":function(data, type, row){
            	return '<button type="button" onclick="resetpwd('+data+')" title="重置后的新密码与登录名一致" class="mb-sm btn btn-warning"><em class="fa fa-edit">重置密码</em></button>';
            }
        }
        ]
	});
	$('.tableSearch').append("<input type='text'>");
	$('.tableSearch').append("<button class=\"mb-sm btn btn-info\" id=\"searchBtn\"><em class=\"fa fa-search\">&nbsp;搜索</em></label>")
	$('.tableSearch input').css('width', '250px');
	$('.tableSearch input').css('border', '1');
	$('.tableSearch input').css('margin-right', '8px');
	$('.tableSearch input').css('margin-bottom', '5px');
	$('.tableSearch input').attr('id', 'sSearch');
	$('.tableSearch input').attr('placeholder', '模糊查询'); 
	
    
	 }
    
    	return {
    		init:function(){
    			initUserList();
    			$("#searchBtn").click(function () {
    				userListTable.api().ajax.reload();
				});
    		}
    	}
    }();
	    $(function(){
	    	userManager.init();
	    	$('.chosen-select').chosen();
	    });
	    
	    function resetpwd(loginName){
	    	 $.ajax({
	 			type : "post",
	 			url : ctx + "/sys/user/resetpwd.do",
	 			data: {'loginName':loginName},
	 			dataType : "json",
	 			success : function(data) {
	 				if (data.success == "success") {
	 					notyMsg("重置用户密码成功!","danger");
	 				}else{
	 					notyMsg("重置用户密码失败!","error");
	 				}
	 			},
	 			error : function( objAJAXRequest, strError) {
	 				notyMsg("重置用户密码失败!","error");
	 			}
	 		});
	    }
    </script>
</head>
<body>
<div class="content-wrapper">
    <h3>系统管理/用户维护</h3>
    <div class="row">
   		<div class="col-lg-12">
	    	<div class="panel panel-info">
	    	<div class="panel-heading">
	    		<div class="text-left">
			          <em class="fa fa-users fa-1x">&nbsp;用户列表</em>
			          <div class="pull-right">
			           
			          </div>
			         
			       </div>
	    	</div>
	    		<div class="panel-body">
			     <table class="table table-bordered table-hover" id="userTab" >
                </table>	
			    </div>
	    	</div>
    	</div>
    </div>
</div>

</body>

</html>